﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     ActivationCode业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/11/5
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class ActivationCodeSqlMapDao : BaseSqlMapDao, IActivationCodeDao
    {
        private static ActivationCodeSqlMapDao instance = null;
        private static object syncRoot = new object();

        private ActivationCodeSqlMapDao()
        {
            //
            // TODO: 此处添加ActivationCodeSqlMapDao的构造函数
            //
        }
        public static IActivationCodeDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new ActivationCodeSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectActivationCodeByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<ActivationCode> GetList()
        {
            try
            {
                return ExecuteQueryForList<ActivationCode>("SelectActivationCode", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<ActivationCode> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<ActivationCode>("SelectActivationCodeByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="ACID"></param>
        /// <returns></returns>
        public ActivationCode GetDetail(System.String acid)
        {
            try
            {
                return ExecuteQueryForObject<ActivationCode>("SelectActivationCode", acid) as ActivationCode;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过对象得到明细
        /// </summary>
        /// <param name="ACID"></param>
        /// <returns></returns>
        public ActivationCode GetDetail(ActivationCode code)
        {
            try
            {
                return ExecuteQueryForObject<ActivationCode>("SelectActivationCode", code) as ActivationCode;
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="activationcode"></param>
        /// <returns></returns>
        public object Add(ActivationCode activationcode)
        {
            //int id = GetId("ActivationCode");
            //activationcode.ACID = id;

            try
            {
                return ExecuteInsert("InsertActivationCode", activationcode);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="activationcode"></param>
        /// <returns></returns>
        public int Update(ActivationCode activationcode)
        {
            try
            {
                return ExecuteUpdate("UpdateActivationCode", activationcode);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ACID"></param>
        /// <returns></returns>
        public int Delete(System.String acid)
        {
            try
            {
                return ExecuteDelete("DeleteActivationCode", acid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="activationcode"></param>
        /// <returns></returns>
        public int Delete(ActivationCode activationcode)
        {
            try
            {
                return ExecuteDelete("DeleteActivationCode", activationcode.ACID);
            }
            catch
            {
                throw;
            }
        }
    }
}
